package code.lucamarrocco.struts2.rest;

import static code.lucamarrocco.rest.Cases.*;
import static code.lucamarrocco.rest.Signatures.*;

import org.apache.struts2.dispatcher.mapper.*;

import code.lucamarrocco.rest.*;

public class RestfulActionMapping extends ActionMapping {
	private String uri;

	private RestfulMethod restfulMethod;

	public String getUri() {
		return uri;
	}

	public RestfulMethod getRestfulMethod() {
		return restfulMethod;
	}

	public RestfulActionMapping(String uri, RestfulMethod method) {
		this.uri = uri;
		this.restfulMethod = method;

		setNamespace("");

		setName(asCamelCase(method.getTopic()));
		setMethod(simpleSignatureOf(method));

		if (getParams() != null) getParams().putAll(method.getValues());
		if (getParams() == null) setParams(method.getValues());
	}
}
